package org.millioncall.yueyoga.admin.export;

import java.util.List;

import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.millioncall.yueyoga.admin.model.HomePageTaskRecord;

public class TaskExportTemplate extends AbstractExcelExportTemplate {
	private List<HomePageTaskRecord> records;
	String[] titles = new String[] { "工作安排", "到期时间", "会员编号", "姓名", "手机号", "信息来源", "状态",
			"子状态"};

	public TaskExportTemplate(List<HomePageTaskRecord> records) {
		this.records = records;
	}

	@Override
	public String[] getSheetNames() {
		return new String[] { "任务信息表" };
	}

	@Override
	public String[][] getTitles() {
		return new String[][] { titles };
	}

	@Override
	protected void buildBody(int sheetIndex) {
		Sheet sheet = getSheet(sheetIndex);
		int startIndex = this.getBodyStartIndex(sheetIndex);
		for (int i = 0; i < this.records.size(); i++) {
			HomePageTaskRecord record = this.records.get(i);

			Row row = sheet.createRow(i + startIndex);
			row.setHeight((short) 300);
			int index = 0;
		    String xxly = "";
		    String xy = record.getXxly();
		    String xxy;
		    if(xy==null){
		    	xxy = "";
		    }else{
		    	xxy = record.getXxly().toString();
		    }
		    if("1".equals(xxy)){
		    	xxly = "打进电话";
		    }else if("2".equals(xxy)){
		    	xxly = "打出电话";
		    }else if("3".equals(xxy)){
		    	xxly = "网络";
		    }else if("4".equals(xxy)){
		    	xxly = "拜访";
		    }
			createStyledCell(row, index++, record.getGzap()==null?"":record.getGzap().toString(), this.bodyRowStyle);
			createStyledCell(row, index++, record.getDqsj()==null?"":record.getDqsj().toString(), this.bodyRowStyle);
			createStyledCell(row, index++, record.getHybh()==null?"":record.getHybh().toString(), this.bodyRowStyle);
			createStyledCell(row, index++, record.getHyxm()==null?"":record.getHyxm().toString(), this.bodyRowStyle);
			createStyledCell(row, index++, record.getHysjh()==null?"":record.getHysjh().toString(), this.bodyRowStyle);
			createStyledCell(row, index++, xxly, this.bodyRowStyle);
			createStyledCell(row, index++, record.getHyzt()==null?"":record.getHyzt().toString(), this.bodyRowStyle);
			createStyledCell(row, index++, record.getHyzzt()==null?"":record.getHyzzt().toString(), this.bodyRowStyle);
		}
	}

	@Override
	public String[] getCaptions() {
		return new String[] { "任务信息表" };
	}
}
